<template>
    <div>
        <h3>登录</h3>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">用户名</td>
                    <td><input type="text" v-model="Query.username"></td>
                </tr>
                <tr>
                    <td align="right">密码</td>
                    <td><input type="password" v-model="Query.userpwd"></td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="登录" @click="login" class="btn btn-primary">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import axios from 'axios';
import moment from 'moment';
import { useRoute, useRouter } from 'vue-router';
const Route = useRoute();
const Router = useRouter();

let Query: any = reactive({
    username: '',
    userpwd: ''
})
const login = () => {
    if (Query.username == "") {
        alert("用户名不能为空");
        return;
    }
    if (Query.userpwd == "") {
        alert("密码不能为空");
        return;
    }
    axios({
        url: '/api/User/Login',
        method: 'get',
        params: Query
    })
        .then((res) => {
            console.log(res);
            if (res.data == -1) {
                alert("用户名不存在");
                return;
            }
            else if (res.data == -2) {
                alert("密码错误");
                return;
            }
            else {
                alert("登录成功");
                return;
            }

        })
        .catch((err) => {
            console.log(err);

        })
}




</script>

<style scoped></style>